﻿namespace EasyWeb.Web.UI.Html
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Reflection;
    using System.Text;
    using System.Threading.Tasks;
    using EasyWeb.Design;

    public static class EWFieldDefinitionExtensions
    {
        public static string GetDisplayName(this EWFieldDefinition field)
        {
            if (field == null) { throw new ArgumentNullException("field"); }

            var attribute = field.GetType().GetTypeInfo().GetCustomAttribute<EWDisplayNameAttribute>(true);
            return attribute == null ? null : attribute.Name;
        }
    }
}
